<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户登录</title>
    <link rel="stylesheet" th:href="@{/css/global.css}">
    <link rel="stylesheet" th:href="@{/css/register/style.css}">
    <link rel="stylesheet" th:href="@{/css/login/style.css}">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
</head>
<body class="light-theme">
<div class="theme-toggle">
    <i class="fas fa-moon"></i>
    <label class="switch">
        <input type="checkbox" id="themeSwitch">
        <span class="slider round"></span>
    </label>
    <i class="fas fa-sun"></i>
</div>

<div class="login-container">
    <div class="login-header">
        <h1>用户登录</h1>
        <p>欢迎回来，请验证身份</p>
    </div>

    <form id="loginForm" class="login-form">
        <div class="form-group">
            <label for="loginUsername">用户名/邮箱</label>
            <div class="input-with-icon">
                <i class="fas fa-user"></i>
                <input type="text" id="loginUsername" name="username" required placeholder="请输入用户名或邮箱">
            </div>
            <span class="error-message"></span>
        </div>

        <div class="form-group">
            <label for="loginPassword">密码</label>
            <div class="input-with-icon">
                <i class="fas fa-lock"></i>
                <input type="password" id="loginPassword" name="password" required placeholder="请输入密码">
            </div>
            <span class="error-message"></span>
        </div>

        <!-- 初始隐藏验证码 -->
        <div class="form-group captcha-group" id="loginCaptchaGroup" style="display: none;">
            <label for="loginCaptcha">图形验证码</label>
            <div class="captcha-container">
                <div class="input-with-icon">
                    <i class="fas fa-shield-alt"></i>
                    <input type="text" id="loginCaptcha" name="captcha" placeholder="输入验证码">
                </div>
                <div class="captcha-img" id="loginCaptchaImg"></div>
            </div>
            <span class="error-message"></span>
        </div>

        <div class="form-footer">
            <div class="login-options">
                <div class="remember-me">
                    <input type="checkbox" id="rememberMe">
                    <label for="rememberMe">记住密码</label>
                </div>
                <a href="#" class="forgot-password">忘记密码？</a>
            </div>

            <button type="button" class="login-btn" onclick="login()">
                <span>立即登录</span>
                <i class="fas fa-sign-in-alt"></i>
            </button>

            <div class="register-link">
                没有账号？<a th:href="@{/page/auth/register}">立即注册</a>
            </div>
        </div>
    </form>
</div>

<div id="customAlert" class="custom-alert">
    <div class="alert-content">
        <div class="alert-icon"></div>
        <div class="alert-message"></div>
        <button class="alert-close">&times;</button>
    </div>
</div>
<script th:src="@{/js/global.js}"></script>
<script th:src="@{/js/login-script.js}"></script>
</body>
</html>
